package com.kjlink.internal.report4vue.statictics.controller;

import cn.xuqiudong.common.base.model.BaseResponse;
import com.kjlink.internal.report4vue.base.controller.BaseApiController;
import com.kjlink.internal.report4vue.statictics.response.ApiSummaryResponse;
import com.kjlink.internal.report4vue.statictics.service.ApiSummaryService;
import com.kjlink.internal.workreport.other.model.DayReportSummaryInfo;
import com.kjlink.internal.workreport.other.service.OtherService;
import com.kjlink.internal.workreport.stats.lookup.UserWeekLookup;
import com.kjlink.internal.workreport.stats.service.ProjectTimeStatsService;
import com.kjlink.internal.workreport.stats.vo.EchartsSimpleLineVo;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDate;

/**
 * 描述:
 *
 * @author Vic.xu
 * @since 2024-11-27 13:50
 */
@RestController
public class ApiSummaryController extends BaseApiController {

    @Resource
    private ProjectTimeStatsService projectTimeStatsService;

    @Resource
    private ApiSummaryService apiSummaryService;

    @Resource
    private OtherService otherService;

    @GetMapping("/stat/summary")
    public BaseResponse<ApiSummaryResponse> summary() {
        ApiSummaryResponse summary = apiSummaryService.summary();
        return BaseResponse.success(summary);
    }

    /**
     * 周/月工时统计 柱状图
     *
     * @param lookup
     * @return
     */
    @RequestMapping(value = "/stat/weekBar", method = {RequestMethod.GET, RequestMethod.POST})
    public BaseResponse<EchartsSimpleLineVo> weekBar(@RequestBody UserWeekLookup lookup) {
        return BaseResponse.success(projectTimeStatsService.weekBar(lookup));
    }

    /**
     * 某日填报率汇总信息
     */

    @GetMapping("/stat/fillingSummary")
    public BaseResponse<DayReportSummaryInfo> fillingSummary(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) {
        if (date == null) {
            date = LocalDate.now();
        }
        DayReportSummaryInfo summary = otherService.dayReportSummaryInfo(date);
        return BaseResponse.success(summary);
    }


}
